package com.xu.microservice;

import com.xu.microservice.mapper.MemberDao;
import com.xu.microservice.pojo.Member;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class MemberService {

    @Autowired
    private MemberDao dao;

    public List<Member> findAll() {
        return dao.selectAll();
    }

    public List<Member> findByExample() {
        Example example = new Example(Member.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andLike("name", "%e%");
        return dao.selectByExample(example);
    }

    @Transactional
    public void insert1(String name) {
        dao.insert1(name);
    }
}
